package org.x.chatmod.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.x.chatmod.dto.ChatFriendDTO;
import org.x.chatmod.dto.ChatFriendResponseDTO;
import org.x.chatmod.mapper.ChatFriendMapper;
import org.x.chatmod.service.ChatFriendService;
import org.x.commonmod.config.Result;

import java.util.HashMap;
import java.util.Map;


@RestController
@RequestMapping("/api/Friend")
public class ChatFriendController {

    @Autowired
    private ChatFriendService chatFriendService;
    @Autowired
    private ChatFriendMapper chatFriendMapper;



    /**
     * 添加好友请求
     * chatFriendDTO
     */
    @RequestMapping("/request")
    public Result FriendRequest(@RequestBody ChatFriendDTO chatFriendDTO) {
        Long relationId = chatFriendService.FriendRequest(chatFriendDTO);
        return Result.ok().put("relationId",relationId);
    }
    /**
     * 处理好友请求
     */
    @RequestMapping("/response")
    public Result response(@RequestBody ChatFriendResponseDTO chatFriendResponseDTO) {
        return Result.ok( chatFriendService.response(chatFriendResponseDTO));
    }
    //删除好友
    @RequestMapping("/delete")
    public Result deleteFriend(@RequestParam long relationId) {
       return Result.ok(chatFriendService.deleteFriend(relationId));
    }




}
